home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-05-17 | 2.0 KB | 58 lines | [TEXT/ZBAS] |
- 'V
- 'S
- 'GETRESMENU function By Charles Stricklin
- 'Modified by Dave Kelly for MacTutor, May, 1989
-
- 'This function creates a ZBasic menu from a MENU resource.
- 'The result given is boolean; true if the task is accomplished,
- 'false if there's a problem (i.e. the resource doesn't exist, etc.)
-
- ' resourceID is the resource ID of the menu resource to be used.
- ' menuNumber is the ZBasic number of the menu to be created.
-
- LONG FN GETRESMENU(ResourceID, MenuNumber)
- DEFSTR LONG
- Done=0
- FALSE=0
- MenuBlkSize=14
- Title$=""
- MyHandle&=FN GETRESOURCE(CVI("MENU"),ResourceID)
- LONG IF FN RESERROR=FALSE
- MyPointer&=USR 3(MyHandle&)
- EnableFlags&=PEEK LONG(MyPointer&+10)
- State=VAL(MID$(BIN$(EnableFlags&),32,1))
- LengthTitle=PEEK(MyPointer&+MenuBlkSize)
- FOR Character=1 TO LengthTitle
- Title$=Title$+CHR$(PEEK(MyPointer&+MenuBlkSize+Character))
- NEXT
- MENU MenuNumber,0,State,Title$
- Offset&=MenuBlkSize+LengthTitle+1
- DO
- MenuItem=MenuItem+1:Title$=""
- LengthTitle=PEEK(MyPointer&+Offset&)
- FOR Character=1 TO LengthTitle
- Title$=Title$+CHR$(PEEK(MyPointer&+Offset&+Character))
- NEXT
- Offset&=Offset&+LengthTitle+1
- IconNumber&=PEEK(MyPointer&+Offset&)
- IF IconNumber& THEN Title$=Title$+"^"+RIGHT$(STR$(IconNumber&),1)
- CommandKey=PEEK(MyPointer&+Offset&+1)
- IF CommandKey THEN Title$=Title$+"/"+CHR$(CommandKey)
- MarkChar = PEEK(MyPointer&+Offset&+2)
- IF MarkChar THEN Title$=Title$+"!"+CHR$(MarkChar)
- CharacterStyle=PEEK(MyPointer&+Offset&+3)
- IF FN BITTST(CharacterStyle,0) THEN Title$=Title$+"<B"
- IF FN BITTST(CharacterStyle,1) THEN Title$=Title$+"<I"
- IF FN BITTST(CharacterStyle,2) THEN Title$=Title$+"<U"
- IF FN BITTST(CharacterStyle,3) THEN Title$=Title$+"<O"
- IF FN BITTST(CharacterStyle,4) THEN Title$=Title$+"<S"
- State=VAL(MID$(BIN$(EnableFlags&),32-MenuItem,1))
- Offset&=Offset&+4
- MENU MenuNumber, MenuItem, State, Title$
- UNTIL PEEK(MyPointer&+Offset&)=FALSE
- Done=-1
- END IF
- MyHandle&=USR 7(MyPointer&)
- CALL DETACHRESOURCE(MyHandle&)
- END FN=Done
-